<template>
	<view class="">
		<button type="primary" @click="addTocart(1)">加入购物车</button>
		<button type="primary" @click="addTocart(-1)">移除购物车</button>
		
		<button type="warn" @click="topay()">去微信支付</button>
		<button type="primary" @click="share()">去分享</button>
		<button type="primary" @click="goWebview()">去webview页面跳转</button>
		<button type="primary" @click="showVercode()">出现验证码</button>
		<!-- <navigator url="/pages/weixin/weixin">
			<text>去微信支付</text>
		</navigator> -->
		<sharesdk ref="sharesdk" :contentHeight="480"></sharesdk>
		<vercode ref="vercode" :contentHeight="480"></vercode>
	</view>
	
</template>

<script>
	import sharesdk from '@/components/share/share.vue'
	import vercode from '@/components/vercode/index.vue'
	import cartmodel from '../../common/cart/cart.js'
	
	
	export default{
		components: {
			sharesdk,
			vercode
		},
		onShow() {
			this.$setTitle("Happy先生·购物车")
		},
		onLoad() {
			// #ifdef H5
			this.$ShareSdk.Share({
				title:'六一儿童节',
				content:'六一儿童节,哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈',
				desc:'哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈',
				link:'/pages/tabBar/cart?sharesdk=1'
			})
			// #endif
		},
		//微信小程序分享
		onShareAppMessage: function(res) {
			if (res.from === 'button') {
			}
			return {
				title: '六一儿童节',
				content:'六一儿童节,哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈',
				path: '/pages/tabBar/index',
				imageUrl: '/static/share/1.png',
				success: function(res) {
					console.log('成功', res);
				}
			};
		},
		methods:{
			addTocart(d){
				this.$cartmodel.setCartVal(d)
			},
			topay(){
				let from_uri = '',to_uri='/pages/weixin/weixin'
				uni.navigateTo({
					url: '/pages/weixin/redirect?to_uri='+to_uri
				})
			},
			share(){
				// #ifdef MP-WEIXIN
				this.$refs.sharesdk.toggleMask();
				// #endif
			},
			goWebview(){
				uni.navigateTo({
					url:'/pages/webview/webview?redirecturl='
					+encodeURIComponent('https://happycs.bestcake.com/static/demo/index.html?sign_key=ajfsdfsdf2dsf&article_id=3')
				})
			},
			showVercode(){
				this.$refs.vercode.toggleMask();
			}
		}
	}
</script>

<style>
</style>
